import React, {PureComponent} from 'react'
import {View, Image, StyleSheet, TouchableOpacity, Text, Dimensions, Button, Platform} from 'react-native'
const {width} = Dimensions.get('window')
import color from '../../widget/color'

type Props = {
    navigation:any,
    info: Object,
}

export default class CourseAllCell extends PureComponent<Props> {

    _pushCommentList() {
        this.props.navigation.navigate('CommentListScene')
    }

    _pushCourseDetail() {
        this.props.navigation.navigate('MineCourseDetailScene', {info: this.props.info})
    }

    render() {
        let {info} = this.props

        if (info.subject == 'match') {
            info.subject = '数'
        } else if (info.subject == 'chinese') {
            info.subject = '语'
        } else if (info.subject == 'english') {
            info.subject = '英'
        }
        //2018-02-11
        let year = info.end_date.substr(0, 4)
        let month = info.end_date.substr(5, 2)
        let day = info.end_date.substr(8, 2)
        let end_date = year + '年' + month + '月' + day + '日'

        let start_time = info.start_date.substr(5, 5).replace('-', '月') + '日'
        let end_time = info.end_date.substr(5, 5).replace('-', '月') + '日'

        return (



            <TouchableOpacity style={styles.container} onPress={()=>{this._pushCourseDetail()}}>
                <View style={{flexDirection:'row',backgroundColor:'white',marginTop:15}}>
                    <View style={{backgroundColor:'#db3843',borderRadius:2,padding:3,}}>
                        <Text style={{color:'#FFFFFF',fontWeight:'bold',fontSize:11,}}>{info.subject}</Text>
                    </View>
                    <View style={{backgroundColor:'white',borderRadius:2,padding:2,marginLeft:6,borderColor:'#DB3843',borderWidth:1,marginRight:4}}>
                        <Text style={{color:'#DB3843',fontSize:11,}}>{info.tag}</Text>
                    </View>
                    <Text numberOfLines={1} style={styles.title}>{info.title}</Text>
                </View>
                    <View style={{flexDirection:'row',backgroundColor:'white',marginTop:12,alignItems:'center',}}>
                        <Image style={{width:12,height:12}} source={require('../../../res/img/select/select_time.png')}/>
                        <Text style={[styles.time,{marginLeft:7}]}>{start_time+'到'+end_time}</Text>
                    </View>
                <View style={{flexDirection:'row',backgroundColor:'white',marginTop:15,alignItems:'center',marginBottom:15}}>
                    <View style={{flexDirection:'row',alignItems:'center',}}>
                        <Image style={{width:28,height:28,borderRadius:14}} source={{uri:info.zhu_teacher.img}}/>
                        <View style={{marginLeft:10,justifyContent:'center',height:28}}>
                            <Text style={styles.teacher_show}>讲师</Text>
                            <Text style={styles.teacher}>{info.zhu_teacher.name}</Text>
                        </View>
                    </View>
                    <View style={{flexDirection:'row',alignItems:'center',marginLeft:30}}>
                        <Image style={{width:28,height:28,borderRadius:14}} source={{uri:info.fu_teacher.img}}/>
                        <View style={{marginLeft:10,justifyContent:'center',height:28}}>
                            <Text style={styles.teacher_show}>辅导</Text>
                            <Text style={styles.teacher}>{info.fu_teacher.name}</Text>
                        </View>
                    </View>
                </View>
            </TouchableOpacity>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        marginLeft: 12,
        marginRight: 12,
        backgroundColor: 'white',
        borderRadius: 5,
        flex: 1,
        shadowColor: '#B5B5B6',
        shadowOffset: {h: 2, w: 2},
        shadowRadius: 1,
        shadowOpacity: 0.4,
        paddingLeft: 12,
    },
    title: {
        fontWeight: 'bold',
        color: 'rgba(0,0,0,0.8)',
        fontSize: 16,
        width: (width - 100)
    },
    time: {
        fontSize: 12,
        color: 'rgba(0,0,0,0.5)',
        fontWeight: '200',
    },
    teacher: {
        marginTop: 4,
        fontSize: 9,
        color: 'rgba(0,0,0,0.4)',
    },
    teacher_show: {
        fontSize: 9,
        color: 'rgba(0,0,0,0.8)',

    },
})